using System.Diagnostics;
using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService.Symbols;

public class DmsPropertySymbol : AbstractSymbol
{
    internal DmsPropertySymbol(SectionSymbol containingSymbol, DmsProperty property) : base(SymbolKinds.DmsProperty)
    {
        Declaration = property;
        ContainingSymbol = containingSymbol;
        NormalizedValue = string.Empty;
    }
    
    
    public DmsProperty Declaration { get; }
    
    public override SectionSymbol ContainingSymbol { get; }
    
    public object? NormalizedValue { get; internal set; }

    public override bool Redeclare(ISymbol symbol)
    {
        Debug.Assert(symbol.Kind == SymbolKinds.DmsProperty);
        LocationMap.AddLocation(symbol.GetFirstLocation());
        // 更新成新的值
        NormalizedValue = ((DmsPropertySymbol)symbol).NormalizedValue;
        return true;
    }
}